package algorithm.tr;

import java.util.Arrays;
import java.util.List;

/**
 * @author dengzhiyuan
 * @version 1.0
 * @describe
 * @time 2022/11/26 18:29
 */
public class Media {


    public static void main(String[] args) {
        new Media().abc(Arrays.asList(1,2,3,4,5,6,7,8,9,10));
    }

    public void abc(List<Integer> a){
        //偶数
        Integer sum1= a.get(0);
        //计算
        Integer sum2= a.get(1);
        String calc1 = "*";
        String calc2 = "*";

        for (int i = 2; i < a.size(); i++) {
            Integer mid = a.get(i);
            if(i % 2 == 0){
                if(calc1.equals("*")){
                    sum1 = sum1 * mid;
                }else {
                    sum1 = sum1 + mid;
                }
                if(calc1.equals("*")){
                    calc1 = "+";
                }else {
                    calc1 = "*";
                }
            }else {
                if(calc2.equals("*")){
                    sum2 = sum2 * mid;
                }else {
                    sum2 = sum2 + mid;
                }
                if(calc2.equals("*")){
                    calc2 = "+";
                }else {
                    calc2 = "*";
                }
            }
        }
        System.out.printf("sum1="+sum1);
        System.out.printf("sum2="+sum2);
    }

}
